package com.clwl.supervise.superviseapp.mapper.supervise;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.clwl.supervise.superviseapp.entity.supervise.JgCheckContent;
import com.clwl.supervise.superviseapp.entity.supervise.JgDailyContent;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

@Mapper
public interface JgDailyContentMapper extends BaseMapper<JgDailyContent> {

    /**
     * 查询标准列表，携带已经检查完成的
     *
     * @param templateStandardId
     * @param dailyStandardId
     * @return
     */
    List<Map<String, Object>> selectByStandardId(@Param("templateStandardId") Object templateStandardId,
                                                 @Param("dailyStandardId") Object dailyStandardId,
                                                 @Param("riskCodeList") List riskCodeList
    );

    /**
     * 获取社会评分检查内容
     * @param templateStandardId
     * @param liabilityStandardId
     * @return
     */
    List<Map<String, Object>> selectLiabilityStandardId(@Param("templateStandardId") Object templateStandardId, @Param("liabilityStandardId") Object liabilityStandardId);

    /**
     * 获取检查内容记录
     *
     * @param contentId jg_check_content表id
     * @param id        jg_daily_standard表id
     * @return
     */
    JgDailyContent selectByContentAndDailyStandard(@Param("contentId") Long contentId, @Param("dailyStandardId") Long id, @Param("riskCodeList") List<String> riskCode);

    /**
     * 获取检查完的检查单子所有检查项
     *
     * @param checkId 日常检查单id
     * @return
     */
    List<Map<String, Object>> selectByDailyCheckId(@Param("checkId") Long checkId);

    /**
     * 获取检查完的检查单子所有检查项
     *
     * @param checkId 日常检查单id
     * @return
     */
    List<JgDailyContent> selectEntityByDailyCheckId(@Param("checkId") Long checkId);

    /**
     * 查询检查内容的列表
     *
     * @param dailyStandardId 日常检查表id
     * @return
     */
    List<Map<String, Object>> selectDailyContentByStandardId(@Param("dailyStandardId") Long dailyStandardId);

    /**
     * 查询未通过的检查结果内容
     *
     * @param dailyCheckId 日常检查id
     * @return
     */
    List<JgDailyContent> selectNoPassList(Long dailyCheckId);

    /**
     * 动态评分的时候查询标准列表，携带已经检查完成的
     *
     * @param templateStandardId 模板标准id
     * @param dynamicScoringId   动态评分表id
     * @return
     */
    List<Map<String, Object>> selectDynamicByStandardId(@Param("templateStandardId") Object templateStandardId, @Param("dynamicScoringId") Object dynamicScoringId, @Param("riskCodeList") List<String> riskCode);

    List<Map<String, Object>> selectDynamicByAll(@Param("dynamicScoringId") Object dynamicScoringId, @Param("riskCodeList") List<String> riskCode);

    /**
     * 动态评分的时候查询标准列表，携带已经检查完成的
     *
     * @param templateStandardId 模板标准id
     * @return
     */
    List<JgCheckContent> selectDynamicEntityByStandardId(@Param("templateStandardId") String templateStandardId, @Param("riskCodeList") List<String> riskCode);

    /**
     * 计算企业上一年
     *
     * @param companyId
     * @return
     */
    Double selectCheckTotalStore(@Param("companyId") Long companyId, @Param("year") String year);


    void batchInsert(@Param("list") List<JgDailyContent> insertContentList);

    void batchUpdate(@Param("list") List<JgDailyContent> updateContentList);

    List<JgDailyContent> selectListByCheckId(Long checkId);

    void updateSelectionByIds(@Param("list") List<Object> dailyIdList, @Param("selection") String selection);

    List<JgDailyContent> selectByDailyStandard(@Param("dailyStandardId") Long id);

    BigDecimal selectTotalByDailyCheckId(@Param("checkId") Long id);
}